package cn.itcast.order.configuration;

import cn.itcast.order.pojo.Queue;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.context.annotation.Configuration;

import javax.servlet.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author danDong
 * @date 2025-02-17 09:54:03
 */
@Configuration
public class MyFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("" +
                "Web 容器在启动时" +
                "仅会在初始化时被调用一次" +
                "");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("" +
                "核心工作方法" +
                "每一次请求都会调用该方法" +
                "调用 chain.doFilter(request, response) 将请求传递给下一个过滤器或目标资源" +
                "");
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {
        System.out.println("" +
                "Web 容器在销毁时" +
                "仅会执行一次" +
                "");;
    }




    public static void main(String[] args) {
        // 先入先出
        Queue queue = new Queue();
        queue.addQueue("1");
        queue.addQueue("2");
        queue.addQueue("3");
        queue.getAll();
    }

}
